<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>退款明细</title>
  <link rel="stylesheet" href="../../../layui/css/layui.css">
  <script src="../../../layui/layui.js"></script>
</head>
<style type="text/css">
  body{
    height: 100%;
    width: 100%;
    margin-top: 11px;
  }


</style>

<body >
<!-- 内容主体区域 -->
<div class="layui-fluid layui-form">
  <div class="layui-form-item">
    <div class="layui-input-inline " style=" width: 638px;">

      <!--<button class="layui-btn layui-btn-normal qidong">启用账户</button>-->
      <!--<button class="layui-btn layui-btn-normal tingzhi">停止账户</button>-->
      <!--<button class="layui-btn layui-btn-normal shouquan">授权</button>-->
<!--      <button class="layui-btn">默认按钮</button>
      <button class="layui-btn layui-btn-normal">百搭按钮</button>-->
     </div>
    <!--<div class="layui-inline">-->
      <!--<label class="layui-form-label">搜索选择框</label>-->
      <!--<div class="layui-input-inline">-->
        <!--<select name="modules"  lay-search="" class="userKey">-->
          <!--<option value="">直接选择或搜索选择</option>-->
          <!--<option value="user_code">项目名称</option>-->
          <!--&lt;!&ndash;<option value="user_name">用户名称</option>&ndash;&gt;-->
          <!--&lt;!&ndash;<option value="email">email</option>&ndash;&gt;-->
        <!--</select>-->
      <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-inline">-->
      <!--<div class="layui-input-inline">-->
        <!--<input type="text" name="userKey" class="layui-input userKeyValue ">-->
      <!--</div>-->
      <!--<div class="layui-input-inline">-->
        <!--<button class="layui-btn layuiadmin-btn-admin layui-btn-normal check" lay-submit="" lay-filter="LAY-user-back-search">-->
          <!--<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>-->
        <!--</button></div>-->
    <!--</div>-->
    <div class="layui-inline">
      <div class="layui-input-inline">
        <select name="modules"  lay-search="" class="listMember">
          <option value="">选择会员</option>
        </select>
      </div>
    </div>
    <!--<div class="layui-inline">-->
      <!--<label class="layui-form-label">日期范围</label>-->
      <!--<div class="layui-input-inline">-->
        <!--<input type="text" class="layui-input" id="toDays" placeholder=".">-->
      <!--</div>-->
    <!--</div>-->
    <div class="layui-inline">
      <!-- <div class="layui-input-inline">
           <input type="text" name="userKey" class="layui-input memberName ">
       </div>-->
      <div class="layui-input-inline">
        <button class="layui-btn layuiadmin-btn-admin layui-btn-normal check" lay-submit="" lay-filter="LAY-user-back-search">
          <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
        </button></div>
    </div>

  </div>
</div>

<div id="pTable" >
  <table id="layui_table_id" class="layui-table" lay-skin="line" lay-filter="test" style="width: 1680px">

  </table>
<!--  <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  </script>-->
  <div id="laypage"></div>
</div>
</body>
</html>

<script type="text/javascript">
  layui.use(['form','laydate','layer','table','laypage','util'],function(){
    var form = layui.form;
    var laydate=layui.laydate;
    var $ = layui.$;
    //日期范围
    laydate.render({
      elem: '#toDays'
      ,type: 'datetime',
      range: '~'
    });
    productsearch(1);
    getOtherInfo();
    function getOtherInfo(storeId) {
      $.ajax({
        type:'GET',
        url:'/hy/basic/recharge/getMemberInfo',
        data: {recordId:storeId},
        success: function(data){
          var listMember = data.listMember;
          for(index in listMember){
            var temp = "";
            temp = "<option value="+listMember[index].recordId+">"+listMember[index].memberName+"</option>";
            $(".listMember").append(temp);
            form.render();//表单重新渲染，要不然添加完显示不出来新的option
          }
          form.render();//表单重新渲染，要不然添加完显示不出来新的option
        },
        error:function(data){
          alert("操作失败");
          console.log(data);
        }
      })
    }



    function productsearch(page,memberId,toDays) {

      var table = layui.table,
      laydate = layui.laydate,
      laypage = layui.laypage;
      var form = layui.form;
      table.render({
        elem : '#layui_table_id',
        url : '/hy/basic/consumption/queryProductReject',
        cols : [ [
              {checkbox: true,
                filter:'test'
              }
              ,
              {
                field : 'member_name',
                title : '顾客名',
                align : 'center'
              }
              , {
                field : 'product_name',
                title : '购买产品',
                align : 'center'
              }
              , {
                field : 'amount',
                title : '购买金额',
                align : 'center'
              }
              , {
                field : 'method_payed',
                title : '支付方式',
                align : 'center',
                templet: '#method_payed'

              }
              , {
                field : 'create_date',
                title : '创建时间',
                align : 'center'
              }



        ] ],
        page : true,
        where : {
          memberName:memberId,cardType:'3',toDays:toDays
        },
        responseHandler: function (res, curr,count) {
          $('#pageNum').val(curr);
          return {
            "count": res.total,
            "data": res.data,
            "code": 0,//code值为200表示成功
            "msg": ""
          }
        },
        done : function(res, curr, count) {
          console.log(res)
          $('#pageNum').val(curr);

        }
      })
      // table.on('checkbox(test)', function(obj){
      //   console.log(layui.table.checkStatus('layui_table_id'));
      // });
     // 监听工具条
      table.on('tool(test)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
        var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
        if (layEvent == 'detail') {
          queryById(data.id);
        } else if (layEvent == 'del') {
          //alert(data.id)
          var pageNum = $('#pageNum').val();
          layer.confirm('真的删除行么', function(index){
            deleteById(data.id);
            layer.close(index);
            //向服务端发送删除指令
          });
        } else if (layEvent === 'edit') {
          layer.msg('编辑操作');
        }
      });
      //常规用法
      laydate.render({
        elem : '#createDate'
      });
      //常规用法
      laydate.render({
        elem : '#processingTime'
      });

    }

    $(".check").on("click", function() {
      /*  var memberName = $(".memberName").val();
        var userKey=$('.userKey option:selected').val();*/
      var memberName =  $(".listMember option:selected").text();
      var toDays = $('#toDays').val();
      if(memberName=='选择会员'){
        memberName = "";
      }
      productsearch(1,memberName,toDays);
    })
    $(".tingzhi").on("click",function(){
      var data = layui.table.checkStatus('layui_table_id').data;
      if(data.length>1||data.length<1){
        alert("请选中一条数据");
        return false;
      }
      $.ajax({
        type:'POST',
        url:'/admin/systemUsers/disableUser.handler',
        data: {userId:data[0].recordId},
        success: function(data){
          alert("操作成功！");
          productsearch(1);
        },
        error:function(data){
          alert("操作失败");
          console.log(data);
        }
      })
    })


    $(".qidong").on("click",function(){
      var data = layui.table.checkStatus('layui_table_id').data;
      if(data.length>1||data.length<1){
        alert("请选中一条数据");
        return false;
      }
      $.ajax({
        type:'POST',
        url:'/admin/systemUsers/enableUser.handler',
        data: {userId:data[0].recordId},
        success: function(data){
          alert("操作成功！");
          productsearch(1);
        },
        error:function(data){
          alert("操作失败");
          console.log(data);
        }
      })
    })
      $(".shouquan").on("click",function(){
          var data = layui.table.checkStatus('layui_table_id').data;
          if(data.length<1){
              alert("请选中一条数据");
              return false;
          }
          layer.open({
              type:2,
              area:[482+'px',315+'px'],
              fix:false,
              offset: '80px',
              maxmin:true,
              shadeClose:true,
              scrollbar: false,
              shade:0.4,
              title:'授权',
              content:['authorize.html'],
              success:function(layero,index){
                  var iframe = window['layui-layer-iframe' + index];
                  // 向子页面的全局函数child传参
                  iframe.child(data[0]);
                  console.log("成功");
              },
              fail:function(data){
                  console.log(data);
              }
          })
      })


    $(".deleteUser").on("click",function(){
      var data = layui.table.checkStatus('layui_table_id').data;
      if(data.length<1){
        alert("请选中一条数据");
        return false;
      }
      var recordIdList = [];
      for(var i=0 ;i<data.length;i++){
        var id = data[i].recordId;
        var temp =id+"";
        recordIdList.push(temp);
      }
      console.log(recordIdList);
      $.ajax({
        type:'POST',
        url:'/hy/basic/serviceSuite/batchDelete',
        //data: JSON.stringify(deleteList),
        data: JSON.stringify(recordIdList),
        contentType: "application/json",
        success: function(data){
          alert("操作成功！");
          productsearch(1);
         // window.parent.location.reload(); //刷新父页面
         // var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
          //parent.layer.close(index);  // 关闭layer

        },
        error:function(data){
          alert("操作失败");
          console.log(data);
        }
      })

    })

    $(".addService").on("click",function(){
      layer.open({
        type:2,
        area:["850px","650px"],
        fix:false,
        offset: '80px',
        maxmin:true,
        shadeClose:true,
        scrollbar: false,
        shade:0.4,
        title:'新增套卡',
        content:['add_service_suite.html'],
        success:function(layero,index){
          console.log("成功");
          var iframe = window['layui-layer-iframe' + index];
          var salonId=2;
          iframe.child(salonId);

        },
        fail:function(data){
          console.log(data);
        }
      })
    })
    $(".updateUser").on("click",function(){
      console.log(layui.table.checkStatus('layui_table_id'));
      var data = layui.table.checkStatus('layui_table_id').data;
      if(data.length >1 || data.length == 0){
        alert("请选中一条数据");
        return false;
      }

      layer.open({
        type:2,
        area:["850px","650px"],
        fix:false,
        offset: '80px',
        maxmin:true,
        shadeClose:true,
        scrollbar: false,
        shade:0.4,
        title:'修改项目',
        content:['update_service_suite.html'],
        success:function(layero,index){
          // 获取子页面的iframe
          var iframe = window['layui-layer-iframe' + index];
          // 向子页面的全局函数child传参
          iframe.child(data[0]);
          console.log("成功");
        },
        fail:function(data){
          console.log(data);
        }
      })
    })

  });
  function method_payed(t){
     if(t==0){
       return '微信';
     }else if((t==1)){
       return '支付宝';
     }else if((t==2)){
       return '银行卡';
    }else if((t==3)){
       return '现金';
     }else if((t==10)){
       return '账户余额';
     }else if((t==11)){
       return '充值卡余额';
     }
    return util.toDateString(t1);
  }


</script>


<script type="text/html" id="method_payed">


        {{ method_payed(d.method_payed) }}


</script>

